package written.test;

import edu.princeton.cs.algs4.In;

import java.util.*;

/**
 * @Author: Dang Qi
 * @Date: 2021/4/1  19:13
 * @Description:
 */
public class Main7 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        String[] p0 = sc.nextLine().split(" ");
        Package[] packages = new Package[p0.length];
        for(int i = 0; i < p0.length; i++){

            String[] tmp = p0[i].split(",");
//            System.out.println(Arrays.toString(tmp));
            Set<Integer> set = new HashSet<>();
            for(int j = 0; j < tmp.length; j++){
                set.add(Integer.parseInt(tmp[j]));
            }
            packages[i] = new Package(set, sc.nextInt());
//            System.out.println(packages[i]);
        }
        sc.nextLine();
        String[] nd = sc.nextLine().split(" ");
        Set<Integer> set = new HashSet<>();
        for(int i = 0; i < nd.length; i++){
            set.add(Integer.parseInt(nd[i]));
        }
        Package need = new Package(set, Integer.MAX_VALUE);
//        System.out.println(Arrays.toString(need));

    }
    public static int dfs(Package[] packages, int i, Package need, Package ans){
        if(i==packages.length) return 0;
        if(need.equals(ans)) return 0;
        int a = packages[i].val ;
        return 0;
    }
    public static class Package implements Comparable{
        public Set<Integer> set = null;
        public int val = 0;
        public Package(Set<Integer> set, int val){
            this.set = set;
            this.val = val;
        }

        @Override
        public String toString() {
            return "Package{" +
                    "set=" + set +
                    ", val=" + val +
                    '}';
        }

        @Override
        public boolean equals(Object obj) {
            Package p = (Package)obj;
            return set.equals(p.set);
        }

        @Override
        public int compareTo(Object o) {
            Package p = (Package)o;
            return this.val - p.val;
        }
    }
    public static List<String> f(String s){

        return null;
    }
}